<?php
    global $_W, $_GPC;
    if(!$operation = $_GPC['op']){
        $operation = 'index';
    }
    if($operation == 'index'){
        $params = [
            ':uniacid' => $_W['uniacid']
        ];
        $total = pdo_fetchcolumn('select count(id) from '.tablename('d1sj_card_loan').' where uniacid = :uniacid', $params);
        $page = max($_GPC['page'], 1);
        $psize = 10;
        $pager = pagination($total, $page, $psize);

        $limit = ($page - 1)*$psize . ',' . $psize;
        $list = pdo_fetchall('select * from '.tablename('d1sj_card_loan').' where uniacid = :uniacid order by id limit ' . $limit, $params);
        foreach ($list as $key => &$value) {
                $user_list=pdo_fetch('select id,uid,name from ',tablename('d1sj_card_user')." where uniacid=:uniacid and uid=:uid ",array(':uniacid'=>$_W['uniacid'],':uid'=>$value['recommend_id']));
                $value['recommend']=$user_list['name'];
        }
    }

    if($operation=='delete'){
        $id=$_GPC['id'];
        $group_res=pdo_delete('d1sj_card_loan',array('id'=>$id));
        if($group_res){
            message('删除成功',$this->createWebUrl('loan',array('op'=>'index')),'success');
        }

    }

    include $this->template('web/loan');
?>